<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Strophe.js Basic Cross-Domain Example</title>
  
 <!--  <script type="text/javascript">var flensed="/flensed-1.0/deploy/";</script> -->
  
  <script type='text/javascript'  src='./jquery.min.js'></script>
  <script type='text/javascript'  src='./flensed-1.0/deploy/flXHR.js'></script>

  <script type='text/javascript'  src='./strophejs-1.0.2/strophe.js'></script>
  <script type='text/javascript'  src='./strophejs-1.0.2/plugins/strophe.flxhr.js'></script>
  <script type="text/javascript"  src="./strophejs-1.0.2/plugins/strophe.pubsub.js"></script>

  
  <script type='text/javascript'>
   //var BOSH_SERVICE = 'http://172.16.3.53:5280/http-bind'
	var BOSH_SERVICE = 'http://172.16.3.53/http-bind'
	//var BOSH_SERVICE = '/http-bind'
	var XMPP_DOMAIN = 'xmpptesta.com';
	var PUBSUB_COMPONENT = 'pubsub.xmpptesta.com';
	var topicName = 'myTopic';
	var JID = "user1@xmpptesta.com";
	var Pass="user1";
	
	var connection ;
	$(document).ready(function () {
		connection = new Strophe.Connection(BOSH_SERVICE);
		connection.rawInput = rawInput;
		connection.rawOutput = rawOutput;
		connection.connect(JID,	Pass,onConnect);
		
		
		
	})
	
	
	
	function onConnect(status){
		if (status == Strophe.Status.CONNECTING) {
			log('Strophe is connecting.');
		} else if (status == Strophe.Status.CONNFAIL) {
			log('Strophe failed to connect.');
		} else if (status == Strophe.Status.DISCONNECTING) {
			log('Strophe is disconnecting.');
		} else if (status == Strophe.Status.DISCONNECTED) {
			log('Strophe is disconnected.');
		} else if (status == Strophe.Status.CONNECTED) {
			log('Strophe is connected.');
			connection.send($pres());
			
			connection.pubsub.subscribe(connection.jid,PUBSUB_COMPONENT,topicName,{},function(stanza){
				
			});
		}
	}
	function log(msg) 
	{
	    $('#log').append('<div></div>').append(document.createTextNode(msg));
	}

	function rawInput(data)
	{
	    log('RECV: ' + data);
	}

	function rawOutput(data)
	{
	    log('SENT: ' + data);
	}
  </script>
</head>
<body>
  <div id='log'></div>
</body>
</html>
